'Written by James Smelley on 30AUG05.
'Last updated on 10Feb06
' "Region" and "EndRegion" are code collapse tags that are used in the Admin Script Editor (ASE).

'Region Declare inital objects and variables

	Set objFSO = CreateObject("Scripting.FileSystemObject")
	Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}//./root/cimv2")
	Set wshShell= WScript.CreateObject("wscript.shell")
	Set wshNetwork= WScript.CreateObject("wscript.network")
	Set colItems = objWMI.ExecQuery("SELECT * FROM Win32_TimeZone")
	
	'Set machine name variable for use later
		CMName = WshNetwork.ComputerName
	'Set the current date in UTC	
		CurDT = Year(Now) & Month(Now) & Day(Now) & "_" & Hour(Now) & Minute(Now) & Second(Now)
		
	
	For Each objItem In colItems
		'Set the current timezone
		CTZone = objItem.Caption
	Next
	
	Const HKLM = &H80000002	
	'EndRegion

'Region Create supporting directory structure if not present
	
	'Identify the Present Working Directory (PWD)
	PWD = Left(WScript.ScriptFullName,(Len(WScript.ScriptFullName) - (Len(WScript.ScriptName) + 1)))
	'Create an output folder in the PWD
	RootFolder = PWD & "\Output"
	'Create a folder for this machine in the outout directory
		'folder will be the same name As the machine name
	OutputFolder = RootFolder & "\" & CMName
	'Set the name of the output file
	OpenFile = CMName & "_" & CurDT & ".txt"
	'Verify or create the folder structure
	If objFSO.FolderExists(RootFolder) Then
		If objFSO.FolderExists(OutputFolder) = False Then 
			Set objFolder = objFSO.CreateFolder(OutputFolder)
		End If
	Else
		Set objFolder = objFSO.CreateFolder(RootFolder)
		Set objFolder = objFSO.CreateFolder(OutputFolder)
	End If

'EndRegion

'Region Open output file

	'Create the out
	Set objLogFile = objFSO.CreateTextFile(OutputFolder & "\" & OpenFile, True)

	'EndRegion

'region Write intro

	objLogFile.Writeblanklines(1) 
	objLogFile.Writeline "This information was collected on: " & Date & " at " & Time
	TBreak
	objLogFile.Writeline "*     This section displays General information about          *"
	objLogFile.Writeline "*     the  system.                                             *"
	BBreak

'endregion

'Region General OS Info
	
	'region OS Info
	Set colOSInfo = objWMI.ExecQuery("SELECT * FROM Win32_OperatingSystem")
	
	objLogFile.WriteLine "Operating System Information:"
	For Each objInfo In colOSInfo
		'Set machine name variable for use later
		CMName = objInfo.CSName
		NumberofProcesses = objInfo.NumberOfProcesses
		
		'Parse and define the OS Name
		Resultstr = Left(objInfo.Name,InStr(1,objInfo.Name, "|", 1)-1)
		objLogFile.WriteLine vbtab & "Operating System:------------------------- " & Resultstr & " " & objInfo.CSDVersion  & " (Build #: " & objInfo.BuildNumber & ")"
		objLogFile.WriteLine vbtab & "OS Caption:------------------------------- " & objInfo.Caption
		objLogFile.WriteLine vbtab & "Machine Name:----------------------------- " & objInfo.CSName
		objLogFile.WriteLine vbtab & "System Install Date:---------------------- " & CustDate(objInfo.InstallDate)
		objLogFile.WriteLine vbtab & "Current Time Zone:------------------------ " & CTZone
		objLogFile.WriteLine vbtab & "Last Bootup Time:------------------------- " & CustDate(objInfo.LastBootUpTime)
		objLogFile.WriteLine vbtab & "OS Serial Number:------------------------- " & objInfo.SerialNumber
		objLogFile.Writeblanklines(1) 
		
		'For use in memory section
		VirMem = objInfo.TotalVirtualMemorySize
		VisMem = objInfo.TotalVisibleMemorySize
	Next
	'endregion
	
	'region Storage Information
	
		Const HARD_DISK = 3
		Set colDisks = objWMI.ExecQuery("Select * from Win32_LogicalDisk Where DriveType = " & HARD_DISK & "")
			
		objLogFile.WriteLine "Storage Information:"
		
		'Define the column headers
		Col1Header = "Drive Letter"
		Col2Header = "Storage Space"
		Col3Header = "Free Disk Space"
		Col4Header = "Volume Serial Number"
	
		For Each objDisk In colDisks 'Column widths, last column not set.
			GetMaxWidth objDisk.DeviceID, C1, Col1Header
			GetMaxWidth Round((objDisk.size / 1073741824), 2) & " GB", C2, Col2Header
			GetMaxWidth Round((objDisk.FreeSpace / 1048576), 2) & " MB", C3, Col3Header
		Next
		
		Header = Col1Header & Space(C1 - Len(Col1Header)) & _
					Col2Header & Space(C2 - Len(Col2Header)) & _
					Col3Header & Space(C3 - Len(Col3Header)) & _
					Col4Header 
					
		objLogFile.Writeline vbtab & Header
		objLogFile.Write vbtab
		
		For i = 1 To Len(Header)
			objLogFile.Write "-"
		Next

		objLogFile.Writeblanklines(1) 
	
		On Error Resume Next 'Turns error checking off. 
		For Each objDisk In colDisks
		
			'Define the column objects
			Col1Object = objDisk.DeviceID
			Col2Object = Round((objDisk.size / 1073741824), 2) & " GB"
			Col3Object = Round((objDisk.FreeSpace / 1048576), 2) & " MB"
			Col4Object = objDisk.VolumeSerialNumber
			
			objLogFile.WriteLine vbtab & _
				Col1Object & Space(C1 - Len(Col1Object)) & _
				Col2Object & Space(C2 - Len(Col2Object)) & _
				Col3Object & Space(C3 - Len(Col3Object)) & _
				Col4Object
		Next
		
		On Error GoTo 0 'Turns error checking back on
		objLogFile.Writeblanklines(1) 
		
		'region Clear all section variables
			Col1Header = vbNothing
			Col2Header = vbNothing
			Col3Header = vbNothing
			Col4Header = vbNothing
			Col1Object = vbNothing
			Col2Object = vbNothing
			Col3Object = vbNothing
			Col4Object = vbNothing
			C1 = vbNothing
			C2 = vbNothing
			C3 = vbNothing
		'endregion
	'endregion

	'region Memory Information
	
			Set colItems = objWMI.ExecQuery("SELECT * FROM Win32_ComputerSystem")
			
			objLogFile.WriteLine "Memory Information:"
			For Each objItem In colItems
				objLogFile.WriteLine vbtab & "Total Visible Memory Size:---------------- " & Round((VisMem / 1024), 2) & " MB"
				objLogFile.WriteLine vbtab & "Total Physical Memory:-------------------- " & Round((objItem.TotalPhysicalMemory / 1048576), 2) & " MB"
				objLogFile.WriteLine vbtab & "Total Virtual Memory Size:---------------- " & Round((VirMem / 1024), 2) & " MB"
				objLogFile.Writeblanklines(1) 
			Next
	'endregion

	'region CPU Information
	
			Set colItems = objWMI.ExecQuery("SELECT * FROM Win32_Processor")
		
			objLogFile.WriteLine "Processor(s) Information:"
			For Each objItem In colItems
				objLogFile.WriteLine vbtab & "Processor Name: -------------------------- " & LTrim(objItem.Name)
				objLogFile.WriteLine vbtab & "Processor Manufacturer:------------------- " & objItem.Manufacturer
				objLogFile.WriteLine vbtab & "Processor Max Clock Speed:---------------- " & Round(objItem.MaxClockSpeed / 1024, 2) & " GHz"
				objLogFile.WriteLine vbtab & "Processor Socket Designation:------------- " & objItem.SocketDesignation
				objLogFile.WriteLine vbtab & "Processor L2 Cache Size:------------------ " & objItem.L2CacheSize & " KB"
				objLogFile.WriteLine vbtab & "Processor L2 Cache Speed:----------------- " & objItem.L2CacheSpeed & " MHz"
				objLogFile.WriteLine 
			Next
	'endregion

	'region See if AV is installed and get the definations date
		
		
		Set objRegistry = GetObject("winmgmts:\\.\root\default:StdRegProv")
		strKeyPath = "SOFTWARE\Symantec\SharedDefs"
		strValueName = "DEFWATCH_10" 
		objRegistry.GetStringValue HKLM,strKeyPath,strValueName,Reg_SZValue
		
		objLogFile.WriteLine "AntiVirus Software:"
		If IsNull(Reg_SZValue) Then
			objLogFile.WriteLine "	Symantec Antivirus is not installed."
			objLogFile.WriteLine "	Manually verify alternate AV software is installed."
			objLogFile.WriteLine 
		Else
			Dyear = Mid(Reg_SZValue, InStr(1,Reg_SZValue, ".", 1)-8, 4)
			DMonth = Mid(Reg_SZValue, InStr(1,Reg_SZValue, ".", 1)-4, 2)
			DDay = Mid(Reg_SZValue, InStr(1,Reg_SZValue, ".", 1)-2, 2)
			months = Array("JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC")
			DRev = Mid(Reg_SZValue, InStr(1,Reg_SZValue, ".", 1)+1, 3)
			DDate = DDay & " " & Months(DMonth -1) & " " & Dyear & " Revision: " & DRev
			objLogFile.WriteLine vbtab & "Antivirus installed.:--------------------- " & "Symantec AntiVirus"
			objLogFile.WriteLine vbtab & "Antivirus Definations:-------------------- " & DDate 
			objLogFile.WriteLine 
		End If		
	'endregion

	'Region BIOS Information
		
		Set colBIOS = objWMI.ExecQuery("SELECT * FROM Win32_BIOS")
		
		objLogFile.WriteLine "BIOS Information:"
		For Each objItem In colBIOS
			Iyear = Left(objItem.ReleaseDate,4)
			InMonth = Mid(objItem.ReleaseDate,5,2)
			IDate = Mid(objItem.ReleaseDate,7,2)
			months = Array("blank","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
			BIOSDate = IDate & " " & Months(InMonth) & " " & Iyear
			objLogFile.WriteLine vbtab & "BIOS Manufacturer:------------------------ " & objItem.Manufacturer
			objLogFile.WriteLine vbtab & "BIOS Version:----------------------------- " & objItem.Version
			objLogFile.WriteLine vbtab & "BIOS Release Date:------------------------ " & BIOSDate
			objLogFile.WriteLine  
		Next
	'EndRegion
	'EndRegion

'Region Network Shares
	TBreak
	objLogFile.Writeline "*     This section displays information about Network          *"
	objLogFile.Writeline "*     shares on the system.                                    *"
	BBreak
	'LDivider
	
	Set colItems = objWMI.ExecQuery("SELECT * FROM Win32_Share")
	
	'Define the column headers
	Col1Header = "Share Name"
	Col2Header = "Share Caption"
	Col3Header = "Share Path"

	For Each objItem In colItems
		GetMaxWidth objItem.Name, C1, Col1Header
		GetMaxWidth objItem.Caption, C2, Col2Header
	Next
	

	objLogFile.Writeline vbtab & _
		Col1Header & Space(C1 -Len(Col1Header)) & _
		Col2Header & Space(C2 -Len(Col2Header)) & _
		Col3Header
		
	objLogFile.Write vbtab 
	
	For i = 1 To Len(Header)
       objLogFile.Write "-"
   Next
	
	objLogFile.Writeline
	
	For Each objItem In colItems
	
		'Define the column objects
		Col1Object = UCase(objItem.Name)
		Col2Object = objItem.Caption
		Col3Object = objItem.Path
		
		objLogFile.WriteLine  vbtab & _
			Col1Object &  Space(C1 -Len(Col1Object)) & _
			Col2Object & Space(C2 -Len(Col2Object)) & _
			Col3Object
	Next
		'region Clear all section variables
			Col1Header = vbNothing
			Col2Header = vbNothing
			Col3Header = vbNothing
			Col1Object = vbNothing
			Col2Object = vbNothing
			Col3Object = vbNothing
			C1 = vbNothing
			C2 = vbNothing
		'endregion
'EndRegion

'Region Local User's Information
	TBreak
	objLogFile.Writeline "*     This section displays information about local user       *"
	objLogFile.Writeline "*     accounts on the system.                                  *"
	BBreak
	
	Set colItems = objWMI.ExecQuery("SELECT * FROM Win32_UserAccount")
	
	'Define the column headers
	Col1Header = "Account Disabled" 
	Col2Header = "Account Locked out"
	Col3Header = "Password Changeable"
	Col4Header = "Password Expires"
	Col5Header = "Password Required"
	
	'Column widths, last column not set.	
	For Each objItem In colItems 
		GetMaxWidth objItem.Disabled, C1, Col1Header
		GetMaxWidth objItem.Lockout, C2, Col2Header
		GetMaxWidth objItem.PasswordChangeable, C3, Col3Header
		GetMaxWidth objItem.PasswordExpires, C4, Col4Header
	Next

	For Each objItem In colItems
		objLogFile.WriteLine vbtab & "User Name:------------------- " & objItem.Name
		objLogFile.WriteLine vbtab & "User FullName:--------------- " & objItem.FullName
		objLogFile.WriteLine vbtab & "User SID:-------------------- " & objItem.SID
		objLogFile.WriteLine vbtab & "User Description:------------ " & objItem.Description
		objLogFile.WriteLine
			
		Header = Col1Header & Space(C1 - Len(Col1Header)) & _
					Col2Header & Space(C2 - Len(Col2Header)) & _
					Col3Header & Space(C3 - Len(Col3Header)) & _
					Col4Header & Space(C4 - Len(Col4Header)) & _
					Col5Header 
			
	objLogFile.Writeline vbtab & Header
	objLogFile.Write vbtab & String(Len(Header), "-")
	objLogFile.Writeline
		
		
		
		'Define the column objects
		Col1Object = objItem.Disabled
			Call bolVert(Col1Object)
		Col2Object = objItem.Lockout
			Call bolVert(Col2Object)
		Col3Object = objItem.PasswordChangeable
			Call bolVert(Col3Object)
		Col4Object = objItem.PasswordExpires
			Call bolVert(Col4Object)
		Col5Object = objItem.PasswordRequired
			Call bolVert(Col5Object)


		objLogFile.WriteLine vbtab & _
			Col1Object & Space(C1 - Len(Col1Object)) & _
			Col2Object & Space(C2 - Len(Col2Object)) & _
			Col3Object & Space(C3 - Len(Col3Object)) & _
			Col4Object & Space(C4 - Len(Col4Object)) & _
			Col5Object 
		
		objLogFile.WriteLine
		objLogFile.WriteLine		
	Next
	
	'region Clear all section variables
		Col1Header = vbNothing
		Col2Header = vbNothing
		Col3Header = vbNothing
		Col4Header = vbNothing
		Col5Header = vbNothing
		Col1Object = vbNothing
		Col2Object = vbNothing
		Col3Object = vbNothing
		Col4Object = vbNothing
		Col5Object = vbNothing
		C1 = vbNothing
		C2 = vbNothing
		C3 = vbNothing
		C4 = vbNothing
	'endregion
'EndRegion

'region Local group information
	TBreak
	objLogFile.Writeline "*     This section displays information about local group      *"
	objLogFile.Writeline "*     accounts on the system and also user assignment.         *"
	BBreak
	'LDivider

	Set colGroups = GetObject("WinNT://.")
	colGroups.Filter = Array("group")
	For Each objGroup In colGroups
		objLogFile.WriteLine vbtab & "Group Name:----------------- " & objGroup.Name
		For Each objUser In objGroup.Members
		objLogFile.WriteLine vbtab & vbtab & "Assigned User:-------------- " & objUser.Name
		Next
	objLogFile.WriteLine
	Next
'endregion

'Region IPCONFIG Information
	
	TBreak
	objLogFile.Writeline "*     This section displays information about the network      *"
	objLogFile.Writeline "*     controller(s) configuration on the system.               *"
	BBreak

	Set objShell = WScript.CreateObject("WScript.Shell")
	Set objExecObject = objShell.Exec("%comspec% /c ipconfig.exe /all")

	Do Until objExecObject.StdOut.AtEndOfStream
		strLine = objExecObject.StdOut.ReadLine()
		objLogFile.WriteLine vbtab & strLine
	Loop
'EndRegion

'Region Path Information
	TBreak
	objLogFile.Writeline "*     This section displays system's Path.                     *"
	BBreak
	
	objLogFile.Writeline vbtab & "System Path: "
	Set WshEnv = WshShell.Environment("PROCESS")
	cPath = Split(WshEnv("PATH"),";")
	For Each x In cPath
		objLogFile.Writeline vbtab & vbtab & x
	Next
	
'EndRegion

'region Path Extension Information
	TBreak
	objLogFile.Writeline "*     This section displays system's Path Extensions.          *"
	BBreak
	
	objLogFile.Writeline "	System Path Extensions:"
	Set WshEnv = WshShell.Environment("PROCESS")
	cPathExt = Split(WshEnv("PATHEXT"),";")
	For Each x In cPathExt
		objLogFile.Writeline vbtab & vbtab & x
	Next	
'endregion

'region Services Information
	TBreak
	objLogFile.Writeline "*     This section displays information about system           *"
	objLogFile.Writeline "*     services.                                                *"
	BBreak

	Set colListOfServices = objWMI.ExecQuery("Select * from Win32_Service")

	'Define the column headers
	Col1Header = "Display Name"
	Col2Header = "Name"
	Col3Header = "Log On As"
	Col4Header = "Start Mode"
	Col5Header = "State"
	Col6Header = "Process ID"
	Col7Header = "Accepts Pause"
	Col8Header = "Accepts Stop"
	
	'Column widths, last column not set.
	For Each objService In colListOfServices 
		GetMaxWidth objService.DisplayName, C1, Col1Header
		GetMaxWidth objService.Name, C2, Col2Header
		GetMaxWidth objService.StartName, C3, Col3Header
		GetMaxWidth objService.StartMode, C4, Col4Header
		GetMaxWidth objService.State, C5, Col5Header
		GetMaxWidth objService.ProcessID, C6, Col6Header
		GetMaxWidth objService.AcceptPause, C7, Col7Header
	Next
	
	Header = Col1Header & Space(C1 - Len(Col1Header)) & _
				Col2Header & Space(C2 - Len(Col2Header)) & _
				Col3Header & Space(C3 - Len(Col3Header)) & _
				Col4Header & Space(C4 - Len(Col4Header)) & _
				Col5Header & Space(C5 - Len(Col5Header)) & _
				Col6Header & Space(C6 - Len(Col6Header)) & _
				Col7Header & Space(C7 - Len(Col7Header)) & _
				Col8Header 
				
	objLogFile.Writeline vbtab & Header
	objLogFile.Write vbtab & String(Len(Header), "-")
	objLogFile.Writeline

	On Error Resume Next 'Turns error checking off. 
	For Each objService In colListOfServices
	
		'Define the column objects
		Col1Object = objService.DisplayName
		Col2Object = objService.Name
		Col3Object = objService.StartName
		Col4Object = objService.StartMode
		Col5Object = objService.State
		Col6Object = objService.ProcessID
		Col7Object = objService.AcceptPause
			Call bolVert(Col7Object)
		Col8Object = objService.AcceptStop
			Call bolVert(Col8Object)
	
		objLogFile.WriteLine vbtab & _
			Col1Object & Space(C1 - Len(Col1Object)) & _
			Col2Object & Space(C2 - Len(Col2Object)) & _
			Col3Object & Space(C3 - Len(Col3Object)) & _
			Col4Object & Space(C4 - Len(Col4Object)) & _
			Col5Object & Space(C5 - Len(Col5Object)) & _
			Col6Object & Space(C6 - Len(Col6Object)) & _
			Col7Object & Space(C7 - Len(Col7Object)) & _
			Col8Object
	Next
	On Error GoTo 0 'Turns error checking back on
	objLogFile.WriteLine
	objLogFile.WriteLine	
	
	'region Clear all section variables
		Col1Header = vbNothing
		Col2Header = vbNothing
		Col3Header = vbNothing
		Col4Header = vbNothing
		Col5Header = vbNothing
		Col6Header = vbNothing
		Col7Header = vbNothing
		Col8Header = vbNothing
		Col1Object = vbNothing
		Col2Object = vbNothing
		Col3Object = vbNothing
		Col4Object = vbNothing
		Col5Object = vbNothing
		Col6Object = vbNothing
		Col7Object = vbNothing
		Col8Object = vbNothing
		C1 = vbNothing
		C2 = vbNothing
		C3 = vbNothing
		C4 = vbNothing
		C5 = vbNothing
		C6 = vbNothing
		C7 = vbNothing
	'endregion
'endregion

'region Processes Information
	TBreak										      '
	objLogFile.Writeline "*     This section displays information about processes        *"
	objLogFile.Writeline "*     currently running on the system.                         *"
	BBreak
	
	Set colProcesses = objWMI.ExecQuery("SELECT * FROM Win32_Process")

	'Define the column headers
	Col1Header = "Name"
	Col2Header = "Executable Path"
	Col3Header = "Running As"
	
	'Column widths, last column not set.
	For Each objProcess In colProcesses
		owner = objProcess.GetOwner(User)
		GetMaxWidth objProcess.Name, C1, Col1Header
		GetMaxWidth objProcess.ExecutablePath, C2, Col2Header
	Next
	
	objLogFile.WriteLine vbtab & "There are currently " & NumberofProcesses & " process running."
	objLogFile.WriteLine
	
	Header = Col1Header & Space(C1 - Len(Col1Header)) & _
				Col2Header & Space(C2 - Len(Col2Header)) & _
				Col3Header
	
	objLogFile.Writeline vbtab & Header
	objLogFile.Write vbtab & String(Len(Header), "-")
	objLogFile.Writeline
	
	On Error Resume Next
	For Each objProcess In colProcesses
	
		owner = objProcess.GetOwner(User)
	
		'Define the column objects
		Col1Object = objProcess.Name
		Col2Object = objProcess.ExecutablePath
		Col3Object = User
	
		objLogFile.WriteLine vbtab & _
			Col1Object & Space(C1 - Len(Col1Object)) & _
			Col2Object & Space(C2 - Len(Col2Object)) & _
			Col3Object
	Next
	
	On Error GoTo 0 'Turns error checking back on
	objLogFile.WriteLine
	objLogFile.WriteLine
	
	'region Clear all section variables
		Col1Header = vbNothing
		Col2Header = vbNothing
		Col3Header = vbNothing
		Col1Object = vbNothing
		Col2Object = vbNothing
		Col3Object = vbNothing
		C1 = vbNothing
		C2 = vbNothing
	'endregion
'endregion

'region Hotfixes Information
	TBreak
	objLogFile.Writeline "*     This section displays information about Hotfixes         *"
	objLogFile.Writeline "*     currently installed on the system.                       *"
	BBreak

	'Determine OS
	Set colSettings = objWMI.ExecQuery("Select * from Win32_OperatingSystem")
	
		For Each objOperatingSystem In colSettings
		strOSCaption = LCase(objOperatingSystem.Caption)
		Select Case True
		Case InStr(strOSCaption, "windows 2000") > 0
			strOS = "Windows 2000"
		Case InStr(strOSCaption, "windows xp") > 0
			strOS = "Windows XP"
		Case InStr(strOSCaption, "windows(r) server 2003") > 0
			strOS = "Windows Server 2003"
		End Select
	Next
	
	strRegBaseUpdate = "SOFTWARE\Microsoft\Updates\" & strOS

	Set colItems = objWMI.ExecQuery("Select * from Win32_QuickFixEngineering",,48)

	'Define the column headers
	Col1Header = "HotFix ID"
	Col2Header = "Installed By"
	Col3Header = "Description"
	Col4Header = "Install Date"
	
	'Column widths, last column not set.
	For Each objItem In colItems		
		GetMaxWidth objItem.HotFixID, C1, Col1Header
		GetMaxWidth objItem.InstalledBy, C2, Col2Header
		GetMaxWidth objItem.Description, C3, Col3Header
	Next
	
	Header = Col1Header & Space(C1 - Len(Col1Header)) & _
				Col2Header & Space(C2 - Len(Col2Header)) & _
				Col3Header & Space(C3 - Len(Col3Header)) & _
				Col4Header
	
	objLogFile.Writeline vbtab & Header
	objLogFile.Write vbtab & String(Len(Header), "-")
	objLogFile.Writeline
	
	Set colItems = objWMI.ExecQuery("Select * from Win32_QuickFixEngineering",,48)
	
	On Error Resume Next
	For Each objItem In colItems
		If objItem.HotFixID <> "File 1" Then
			strInstallDate = Null ' init value
			If objItem.ServicePackInEffect <> "" Then
				strRegKey = strRegBaseUpdate & "\" & objItem.ServicePackInEffect & "\" & objItem.HotFixID
				objReg.GetStringValue HKLM, strRegKey, "InstalledDate", strInstallDate
			End If
			If IsNull(strInstallDate) Then
				strInstallDate = "(none found)"
			End If

			'Define the column objects
			Col1Object = objItem.HotFixID
			Col2Object = objItem.InstalledBy
			Col3Object = objItem.Description
			Col4Object = strInstallDate
		
			objLogFile.WriteLine vbtab & _
				Col1Object & Space(C1 - Len(Col1Object)) & _
				Col2Object & Space(C2 - Len(Col2Object)) & _
				Col3Object & Space(C3 - Len(Col3Object)) & _
				Col4Object
		End If
	Next 
	On Error GoTo 0 'Turns error checking back on
	objLogFile.WriteLine
	objLogFile.WriteLine

	'region Clear all section variables
		Col1Header = vbNothing
		Col2Header = vbNothing
		Col3Header = vbNothing
		Col4Header = vbNothing
		Col1Object = vbNothing
		Col2Object = vbNothing
		Col3Object = vbNothing
		Col4Object = vbNothing
		C1 = vbNothing
		C2 = vbNothing
		C3 = vbNothing
	'endregion
'endregion

'region Startup Application Information
	TBreak
	objLogFile.Writeline "*     This section displays information about commands         *"
	objLogFile.Writeline "*     that run automatically when a user logs onto the         *"
	objLogFile.Writeline "*     system.                                                  *"
	BBreak
	
	Set colItems = objWMI.ExecQuery("SELECT * FROM Win32_StartupCommand")
	
	'Define the column headers
	Col1Header = "Name"
	Col2Header = "Runs For"
	Col3Header = "Command"
	Col4Header = "Location"
	
		'Column widths, last column not set.
	For Each objItem In colItems
		GetMaxWidth objItem.Name, C1, Col1Header
		GetMaxWidth objItem.User, C2, Col2Header
		GetMaxWidth objItem.Command, C3, Col2Header
	Next
	
	Header = Col1Header & Space(C1 - Len(Col1Header)) & _
			Col2Header & Space(C2 - Len(Col2Header)) & _
			Col3Header & Space(C3 - Len(Col3Header)) & _
			Col4Header
	
	objLogFile.Writeline vbtab & Header
	objLogFile.Write vbtab & String(Len(Header), "-")
	objLogFile.Writeline
	
	For Each objItem In colItems
		'Define the column objects
		Col1Object = objItem.Name
		Col2Object = objItem.User
		Col3Object = objItem.Command
		Col4Object = objItem.Location
	
		objLogFile.WriteLine vbtab & _
			Col1Object & Space(C1 - Len(Col1Object)) & _
			Col2Object & Space(C2 - Len(Col2Object)) & _
			Col3Object & Space(C3 - Len(Col3Object)) & _
			Col4Object
	Next
	
	objLogFile.WriteLine
	objLogFile.WriteLine	
	
	'region Clear all section variables
		Col1Header = vbNothing
		Col2Header = vbNothing
		Col3Header = vbNothing
		Col4Header = vbNothing
		Col1Object = vbNothing
		Col2Object = vbNothing
		Col3Object = vbNothing
		Col4Object = vbNothing
		C1 = vbNothing
		C2 = vbNothing
		C3 = vbNothing
	'endregion
'endregion

'region Installed Application Information
	TBreak
	objLogFile.Writeline "*     This section displays information about installed        *"
	objLogFile.Writeline "*     applications on the system.                              *"
	BBreak
		
	strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
	Set objRegistry = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\.\root\default:StdRegProv")
	objRegistry.EnumKey HKLM, strKey, arrSubKeys
	'-----------------------
	'Define the column headers
	Col1Header = "Name"
	Col2Header = "Version"
	Col3Header = "Install Location"
	
	'Column widths, last column not set.
	For Each strSubKey In arrSubKeys
		objRegistry.GetStringValue HKLM, strKey & "\" & strSubKey, "DisplayName", strDisplayName
		objRegistry.GetStringValue HKLM, strKey & "\" & strSubKey, "DisplayVersion", strDisplayVersion
		objRegistry.GetStringValue HKLM, strKey & "\" & strSubKey, "InstallLocation", strInstallLocation
		
		If strDisplayName <> "" Then
			If InStr(1,strDisplayName, "hotfix", 1) = 0 Then
				If InStr(1,strDisplayName, "Security Update for", 1) = 0 Then
					If InStr(1,strDisplayName, "Update for Windows", 1) = 0 Then
						'----------------------------------
						GetMaxWidth strDisplayName, C1, Col1Header
						GetMaxWidth strDisplayVersion, C2, Col2Header
						'-------------------------
						strDisplayName = vbEmpty
						strDisplayVersion = vbEmpty
					End If
				End If
			End If
		End If
	Next

	Header = Col1Header & Space(C1 - Len(Col1Header)) & _
				Col2Header & Space(C2 - Len(Col2Header)) & _
				Col3Header
	
	objLogFile.Writeline vbtab & Header
	objLogFile.Write vbtab & String(Len(Header), "-")
	objLogFile.Writeline
	
	On Error Resume Next
	For Each strSubKey In arrSubKeys
		objRegistry.GetStringValue HKLM, strKey & "\" & strSubKey, "DisplayName", strDisplayName
		objRegistry.GetStringValue HKLM, strKey & "\" & strSubKey, "DisplayVersion", strDisplayVersion
		objRegistry.GetStringValue HKLM, strKey & "\" & strSubKey, "InstallLocation", strInstallLocation
		
		If strDisplayName <> "" Then
			If InStr(1,strDisplayName, "hotfix", 1) = 0 Then
				If InStr(1,strDisplayName, "Security Update for", 1) = 0 Then
					If InStr(1,strDisplayName, "Update for Windows", 1) = 0 Then
						Col1Object = strDisplayName
						Col2Object = strDisplayVersion
						Col3Object = strInstallLocation
						objLogFile.WriteLine vbtab & _
							Col1Object & Space(C1 - Len(Col1Object)) & _
							Col2Object & Space(C2 - Len(Col2Object)) & _
							Col3Object
						strDisplayName = vbEmpty
						strDisplayVersion = vbEmpty
						strInstallLocation = vbEmpty
					End If
				End If
			End If
		End If
	Next
	On Error GoTo 0 'Turns error checking back on
	
	objLogFile.WriteLine
	objLogFile.WriteLine
	
	'region Clear all section variables
		Col1Header = vbNothing
		Col2Header = vbNothing
		Col3Header = vbNothing
		Col1Object = vbNothing
		Col2Object = vbNothing
		Col3Object = vbNothing
		C1 = vbNothing
		C2 = vbNothing
	'endregion
'endregion

'region NetBios Information
	TBreak
	objLogFile.Writeline "*     This section displays NetBIOS information.               *"
	BBreak

		
	Set objShell = WScript.CreateObject("WScript.Shell")
	Set objExecObject = objShell.Exec("%comspec% /c nbtstat -n")

	Do Until objExecObject.StdOut.AtEndOfStream
		strLine = objExecObject.StdOut.ReadLine()
		objLogFile.WriteLine vbtab & strLine
	Loop
'endregion

'region TCP/UDP Connection Information
	TBreak
	objLogFile.Writeline "*     Displays all active TCP connections and the TCP          *"
	objLogFile.Writeline "*     and UDP ports.                                           *"
	BBreak

		
	Set objShell = WScript.CreateObject("WScript.Shell")
	Set objExecObject = objShell.Exec("%comspec% /c netstat -a")
	
	Do Until objExecObject.StdOut.AtEndOfStream
	strLine = objExecObject.StdOut.Readline()
	
	If InStr(1, strLine,"TCP",1) Then 
	
		'region Get and format "TCP" connections
		
		'Parse off the first section
		x1 = InStr(1, Trim(strLine), " ")
		A = Mid(Trim(strLine), 1, x1)
		
		'Alter the line to minus the first section
		NewStrLine = Trim(Right(Trim(strLine), (Len(Trim(strLine)) - x1)))
		
		'Parse off the first section of the new altered line
		x2 = InStr(1, NewstrLine, " ")
		B = Mid(NewstrLine, 1, x2)
		
		'Alter the line to minus the second section
		NewStrLine = Trim(Right(Trim(NewstrLine), (Len(Trim(NewstrLine)) - x2)))
		
		'Parse off the second section of the new altered line
		x3 = InStr(1, NewstrLine, " ")
		C = Mid(NewstrLine, 1, x3)
		
		'Alter the line to minus the third section and set the remainder to equal "D"
		NewStrLine = Trim(Right(Trim(NewstrLine), (Len(Trim(NewstrLine)) - x3)))
		D = NewStrLine
		
		'------------------------------------------------
		
		'Define the column headers
		Col1Header = "Proto"
		Col2Header = "Local Address"
		Col3Header = "Foreign Address"
		Col4Header = "State"

		'Column widths, last column not set.
		GetMaxWidth A, C1, Col1Header
		GetMaxWidth B, C2, Col2Header
		GetMaxWidth C, C3, Col1Header
		
		Header = Col1Header & Space(C1 - Len(Col1Header)) & _
			Col2Header & Space(C2 - Len(Col2Header)) & _
			Col3Header & Space(C3 - Len(Col3Header)) & _
			Col4Header
	
		objLogFile.Writeline vbtab & Header
		objLogFile.Write vbtab & String(Len(Header), "-")
		objLogFile.Writeline

		Col1Object = A
		Col2Object = B
		Col3Object = C
		Col4Object = D

		objLogFile.WriteLine vbtab & _
			Col1Object & Space(C1 - Len(Col1Object)) & _
			Col2Object & Space(C2 - Len(Col2Object)) & _
			Col3Object & Space(C3 - Len(Col3Object)) & _
			Col4Object
			
		'region Clear all section variables
			Col1Header = vbNothing
			Col2Header = vbNothing
			Col3Header = vbNothing
			Col4Header = vbNothing
			C1 = vbNothing
			C2 = vbNothing
			C3 = vbNothing
			A = vbNothing
			B = vbNothing
			C = vbNothing
			D = vbNothing
			'endregion

		'WScript.Echo A & Space(10) & B & Space(10) & C & Space(10) & D
	'endregion	
	
	ElseIf InStr(1, strLine,"UDP",1) Then
	
		'region Get and format "UDP" connections
		
		'Parse off the first section
		x1 = InStr(1, Trim(strLine), " ")
		A = Mid(Trim(strLine), 1, x1)
		'WScript.Echo A
		
		'Alter the line to minus the first section
		NewStrLine = Trim(Right(Trim(strLine), (Len(Trim(strLine)) - x1)))
		'WScript.Echo NewStrLine
		
		'Parse off the first section of the new altered line
		x2 = InStr(1, NewstrLine, " ")
		B = Mid(NewstrLine, 1, x2)
		'WScript.Echo B
		
		'Alter the line to minus the second section
		NewStrLine = Trim(Right(Trim(NewstrLine), (Len(Trim(NewstrLine)) - x2)))
		C = NewstrLine
		'WScript.Echo C
		
		WScript.Echo A & Space(10) & B & Space(10) & C
	'endregion
	
	ElseIf InStr(1, strLine,"IP", 1) Or InStr(1, strLine,"ICMP", 1) Then
		'Write out all others...
		WScript.Echo strLine
	End If
	Loop
'endregion

'region Set completion level
complevel = 1
'endregion

'region Optional registry dump to a seperate file
intAnswer = MsgBox("Do you want to document the registry on this system?", 260, "Regisrty Information")
	If intAnswer = 6 Then
		Set objShell = WScript.CreateObject("WScript.Shell")
		RegCMD = "regedit /e " & Chr(34) & OutputFolder & "\" & CMName & "_Registry\" & CMName & "_RegDump_" & CurDT & ".txt" & Chr(34)
		If objFSO.FolderExists(OutputFolder & "\" & CMName & "_Registry") = False Then
			Set objFolder = objFSO.CreateFolder(OutputFolder & "\" & CMName & "_Registry")
		End If
		objShell.Run RegCMD, 0, True
		complevel = complevel + 3
	End If
'endregion

'region Optional dump of complete directory structure along with file permissions to a seperate file
'TASK - Add warning to msgbox that this will take several minutes to run!
intAnswer = MsgBox("Do you want to document the ACL's for all directories and files on this system?", 260, "Folder and File Information")
	If intAnswer = 6 Then
		intAnswer2 = MsgBox("This could take several minutes to complete, are you sure?", 260, "Folder and File Information")
		If intAnswer2 = 6 Then
			Set objShell = WScript.CreateObject("WScript.Shell")
			If objFSO.FolderExists(OutputFolder & "\" & CMName & "_D&F-ACL") = False Then
				Set objFolder = objFSO.CreateFolder(OutputFolder & "\" & CMName & "_D&F-ACL")
			End If
			Set TmpLogFile = objFSO.CreateTextFile(OutputFolder & "\" & CMName & "_D&F-ACL\" & CMName & "_D&F-ACL's_" & CurDT & ".txt", True)
			Set objExecObject = objShell.Exec("%comspec% /c Cacls c:\ /t /c")
			Do Until objExecObject.StdOut.AtEndOfStream
				strLine = objExecObject.StdOut.ReadLine()
				TmpLogFile.WriteLine strLine
			Loop
			complevel = complevel + 9
			TmpLogFile.Close
		End If
	End If


'intAnswer = MsgBox("Do you want to document the ACL's for all directories and files on this system?", 4, "Folder and File Information")
'	If intAnswer = 6 Then
'		
'		Set objShell = WScript.CreateObject("WScript.Shell")
'		CaclsCMD = "Cacls c:\ /t /c > " & OutputFolder & "\" & CMName & "_Dir & File ACL's\" & CMName & "_D&F-ACL's_" & CurDT & "_.txt"
'		If objFSO.FolderExists(OutputFolder & "\" & CMName & "_D&F-ACL") Then
'			objShell.Run CaclsCMD
'		Else
'			Set objFolder = objFSO.CreateFolder(OutputFolder & "\" & CMName & "_D&F-ACL")
'			objShell.Run CaclsCMD
'		End If
'		complevel = complevel + 9
'	End If
	

'endregion

'region Determine completion level
Select Case complevel
	Case 1 	complevel1 = MsgBox(Space(17) & "Guardian Inventory completed." & (Chr(13)) & (Chr(13)) & _
	"A new output file has been created in the directory that" & (Chr(13)) & _
	"the script was executed from.", 0, "Guardian Inventory Status")
	Case 4 	complevel2 = MsgBox(Space(17) & "Guardian Inventory completed." & (Chr(13)) & _
		Space(23) & "Registry dump completed." & (Chr(13)) & (Chr(13)) & _
		"A new output file has been created in the directory that" & (Chr(13)) & _
		"the script was executed from along with a folder containing" & (Chr(13)) & _
		"the registry dump.", 0, "Guardian Inventory Status")
	Case 10 	complevel3 = MsgBox(Space(17) & "Guardian Inventory completed." & (Chr(13)) & _
		Space(17) & "Directory structure/ACL completed." & (Chr(13)) & (Chr(13)) & _
		"A New output file has been created in the directory that" & (Chr(13)) & _
		"the script was executed from along With a folder containing" & (Chr(13)) & _
		"the directory/ACL listing.", 0, "Guardian Inventory Status")
	Case 13 	complevel4 = MsgBox(Space(17) & "Guardian Inventory completed." & (Chr(13)) & _
		Space(17) & "Directory structure/ACL completed." & (Chr(13)) & _
		Space(23) & "Registry dump completed." & (Chr(13)) & (Chr(13)) & _
		"A New output file has been created in the directory that" & (Chr(13)) & _
		"the script was executed from along With a folder containing" & (Chr(13)) & _
		"the the registry dump and the directory/ACL listing.", 0, "Guardian Inventory Status")
End Select
'endregion

'region Close the ouptput file
objLogFile.Close
'endregion

'region Option, open the output file for review
intAnswer = MsgBox("Would you like to review the inventory file now?", 260, "Guardian Inventory Review")
	If intAnswer = 6 Then
		Set Wshshell= WScript.CreateObject("wscript.shell")
		retcode = Wshshell.run ("notepad " & OutputFolder & "\" & OpenFile, 1, False)
	End If
'endregion

'region Custom Functions

	'Format the date string into a usable format
	Function CustDate(ObjItem)
			Iyear = Left(ObjItem,4)
			InMonth = Mid(ObjItem,5,2) -1
			Iday = Mid(ObjItem,7,2)
			IHour = Mid(ObjItem,9,2)
			IMin = Mid(ObjItem,11,2)
			ISec = Mid(ObjItem,13,2)
			Months = Array("JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC")
			CustDate = IDay & " " & Months(InMonth) & " " & Iyear & " " & IHour & ":" & IMin & ":" & ISec
	End Function

'Space at the top of breaks between areas
	Function TBreak
	
		objLogFile.WriteLine 
		objLogFile.WriteLine 
		For i = 1 To 75
      	objLogFile.Write "#"
   	Next
		objLogFile.WriteLine 
		objLogFile.WriteLine 
		objLogFile.WriteLine 
				For i = 1 To 64
      	objLogFile.Write "*"
   	Next
		objLogFile.WriteLine
		
	End Function
	
'Space below breaks between areas
	Function BBreak
	
		For i = 1 To 64
      	objLogFile.Write "*"
   	Next
		objLogFile.Writeline 
		objLogFile.Writeline 

	End Function
	
'Divider between for loops
	Function LDivider
	
		objLogFile.WriteLine  
		objLogFile.Write vbtab
		For i = 1 To 55
      	objLogFile.Write "-"
   	Next
		objLogFile.WriteLine 
		objLogFile.WriteLine
		
	End Function
	
'Obtain the max width of the element in question
	Function GetMaxWidth(ObjItem, MaxLen, ColItem)
		y = Array(ObjItem)
		For Each x In y
		
			If MaxLen < Len(x) Then
				MaxLen = Len(x) + 6
				MaxLen2 = Len(x)
				If MaxLen2 < Len(ColItem) Then
					MaxLen = Len(ColItem) + 5
				End If
			End If
		Next
	End Function
	
	Function bolVert(bObj)
		If bObj = True Then 
			bObj = "Yes"
		Else
			bObj = "No"
		End If
	End Function
	
'endregion
